home *** CD-ROM | disk | FTP | other *** search
/ MacHome 1999 Game / Image.bin / Role Playing and Strategy / Starbound II.hqx / Starbound II / AI agents / Gypsum.rsrc / ss$t_136 < prev    next >
Encoding:
Text File  |  1998-05-14  |  1.3 KB  |  60 lines

  1. situation barracks
  2. vars
  3.    send : integer;
  4.    success : boolean;
  5.    max : integer;
  6.    hex : integer;
  7.    in : squad;
  8.  
  9. function max_in_barracks() : integer;
  10. vars
  11.    total : integer;
  12.    i : integer;
  13.    
  14. begin
  15.    total := 0;
  16.    i := 1;              // troop type 0 is colonist (which can't be sent down)
  17.    while (i < 8) do
  18.       begin
  19.          total := total + Num_unit_type_barracks(This_barracks(), i);
  20.          i := i + 1;
  21.       end;
  22.    if (total > 8) then
  23.       total := 8;
  24.    return total;
  25. end;
  26.  
  27. function deploy_random_squad(number : integer) : none;
  28. vars
  29.    success : boolean;
  30.    type : integer;
  31.    
  32. begin
  33.    while (number > 0) do
  34.       begin
  35.          type := Random(7) + 1;
  36.          success := Add_unit_to_squad(type);
  37.          if success then
  38.             number := number - 1;
  39.       end;
  40. end;
  41.  
  42. begin
  43.    // first determine the total number of troops on board the fleet
  44.    max := max_in_barracks();
  45.    // Now determine if there are any troops already in the hex
  46.    hex := Structure_hex(This_planet(), This_barracks());
  47.    in := Hex_squad(This_planet(), hex);
  48.    if (in <> nil) then
  49.       begin
  50.          if ((max + Num_units(in)) > 8) then
  51.             max := 8 - Num_units(in);
  52.       end;
  53.    if (max > 0) then
  54.       begin
  55.          send := Random(max) + 1;
  56.          deploy_random_squad(send);
  57.          success := Deploy_squad();
  58.       end;
  59. end;
  60.